<template>
  <div class="app-container">
    <!--      搜索-->
    <div class="head-container">
      <!-- 选择公司-->
      <el-input v-model="query.name" clearable size="small"
                placeholder="输入招聘名字或者手机号"
                style="width: 200px;"
                class="filter-item"
                @keyup.enter.native="crud.toQuery"/>
      <rrOperation :permission="permission"/>
    </div>
    <!--表格渲染-->
    <el-table ref="table" v-loading="crud.loading"
              :data="crud.data"
              style="width: 100%;"
              @selection-change="crud.selectionChangeHandler">
      <el-table-column prop="name" label="姓名" />
      <el-table-column prop="phone" label="手机号"/>
      <el-table-column prop="productId" label="产品线"/>
      <el-table-column prop="degree" :formatter="getDegreeType" label="学历"/>
      <el-table-column prop="jobs" label="应聘岗位"/>
      <el-table-column prop="age" label="年龄" width="50px"/>
      <el-table-column prop="cityId" label="城市" />
      <el-table-column prop="channelId" label="渠道"/>
      <el-table-column prop="sourceId" label="来源途径"/>
      <el-table-column prop="distributeTime" label="分配时间"/>
      <el-table-column
        fixed="right"
        label="操作"
        width="120">
        <template slot-scope="scope">
          <el-button
            @click.native.prevent="deleteRow(scope.$index, tableData)"
            type="text"
            size="small">
            详情
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!--分页组件-->
    <pagination/>
  </div>
</template>
<script>
import CRUD, { crud, form, header, presenter } from '@crud/crud'
import pagination from '@crud/Pagination'
import rrOperation from '@crud/RR.operation'

const defaultForm = { name: null, companyId: null }
export default {
  name: 'Distribution',
  components: { pagination, rrOperation },
  cruds() {
    return CRUD({
      title: '新资源',
      url: 'api/recruit/getNew'
    })
  },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  data() {
    return {
      permission: {
        edit: ['admin', 'recruit:edit'],
        del: ['admin', 'recruit:del']
      },
      form: {
        name: null
      }
    }
  },
  methods: {
    // 获取学位类型
    getDegreeType(row) {
      if (row.degree == '1') {
        return '小学'
      }
      if (row.degree == '2') {
        return '初中'
      }
      if (row.degree == '3') {
        return '高中'
      }
      if (row.degree == '4') {
        return '大专'
      }
      if (row.degree == '5') {
        return '本科'
      }
      if (row.degree == '6') {
        return '硕士'
      }
      if (row.degree == '7') {
        return '博士'
      }
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-input-number .el-input__inner {
  text-align: left;
}
</style>
